import pygame
import sys
import time


# Iniciar pygame
pygame.init()

# Configurar la ventana
ancho = 1200
alto = 163
ventana = pygame.display.set_mode((ancho, alto))
pygame.display.set_caption('METAL SLUG')
pygame.display.update()

# Fondo
mi_fondo = pygame.image.load ("//home/campus100/shushulireshulonproyeh/img/escenario.png")
x,y = 0,0
ventana.blit(mi_fondo, [x,y])
pygame.display.flip()


# Personaje
muneco = pygame.image.load ("//home/campus100/shushulireshulonproyeh/img/muneco.png")
x,y = 5,125
ventana.blit(muneco, [x,y])
pygame.display.flip()
pygame.display.update()


munecoD = pygame.image.load ("//home/campus100/shushulireshulonproyeh/img/munecoD.png")
x,y
ventana.blit(muneco, [x,y])
pygame.display.flip()
pygame.display.update()


muneco2 = pygame.image.load ("//home/campus100/shushulireshulonproyeh/img/muneco2.png")
xa,ya = 1030,95
ventana.blit(muneco2, [xa,ya])
pygame.display.flip()
pygame.display.update()


muneco2D = pygame.image.load ("//home/campus100/shushulireshulonproyeh/img/muneco2D.png")
xa,ya
ventana.blit(muneco2D, [xa,ya])
pygame.display.flip()
pygame.display.update()




# Bucle de eventos personaje 1
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
	if event.type == pygame.KEYDOWN:
			
			if event.key == pygame.K_a:
				ventana.blit(mi_fondo, [0, 0])
				x = x - 5
				ventana.blit(muneco, [x,y])
				ventana.blit(muneco2, [xa,ya])
				pygame.display.flip()
				

			if event.key == pygame.K_d:
				ventana.blit(mi_fondo, [0, 0])
				x = x + 5
				ventana.blit(muneco, [x,y])
				ventana.blit(muneco2, [xa,ya])
				pygame.display.flip()
				
			if event.key == pygame.K_e:
				ventana.blit(mi_fondo, [0, 0])
				print (munecoD)
				ventana.blit(muneco, [x,y])
				ventana.blit(munecoD, [x,y])
				ventana.blit(muneco2, [xa,ya])
				pygame.display.flip()
				
				
			if event.key == pygame.K_w:
				ventana.blit(mi_fondo, [0, 0])
				y = y - 10
				x = x + 5
				ventana.blit(muneco, [x,y])
				ventana.blit(muneco2, [xa,ya])
				pygame.display.flip()
				ventana.blit(mi_fondo, [0,0])
				time.sleep(0.3)
				y = y + 10
				x = x + 5
				ventana.blit(muneco, [x,y])
				ventana.blit(muneco2, [xa,ya])
				pygame.display.flip()



# Personaje 2

			
			
			if event.key == pygame.K_LEFT:
				ventana.blit(mi_fondo, [0, 0])
				xa = xa - 5
				ventana.blit(muneco2, [xa,ya])
				ventana.blit(muneco, [x,y])
				pygame.display.flip()
				

			if event.key == pygame.K_RIGHT:
				ventana.blit(mi_fondo, [0, 0])
				xa = xa + 5
				ventana.blit(muneco2, [xa,ya])
				ventana.blit(muneco, [x,y])
				pygame.display.flip()
				
			if event.key == pygame.K_UP:
				ventana.blit(mi_fondo, [0, 0])
				ya = ya - 10
				xa = xa - 5
				ventana.blit(muneco2, [xa,ya])
				ventana.blit(muneco, [x,y])
				pygame.display.flip()
				ventana.blit(mi_fondo, [0,0])
				time.sleep(0.3)
				ya = ya + 10
				xa = xa - 5
				ventana.blit(muneco2, [xa,ya])
				ventana.blit(muneco, [x,y])
				pygame.display.flip()
				
				
			if event.key ==pygame.K_m:
				ventana.blit(mi_fondo, [0, 0])
				print (muneco2D)
				ventana.blit(muneco2, [xa,ya])
				ventana.blit(muneco2D, [xa,ya])
				ventana.blit(muneco, [x,y])
				pygame.display.flip()
				
